$(document).ready(
	function(){ 
		$('#consoleDlg')[0].style.display = "none";
		
		$("#userSitesDiv")[0].style.display = "none";
		
		$("#gridTable").jqGrid({   
            url:getContextPath()+"/authority/users/getAllUsers.do",   
            datatype: "json",// "local",
            height: 350,   
            colNames:['用户帐号','用户姓名','角色名','手机', '邮件地址', '有效标志', '控制标志'],
			colModel:[
				{name:'id', index:'id', width:70, align:"left"},
		   		{name:'name', index:'name', width:100, align:"left"},
		   		{name:'role.name', index:'role.name', width:150, align:"left"},
		   		{name:'mobilePhone', index:'mobilePhone', width:200, align:"left", sortable:false},
		   		{name:'mailAddress', index:'mailAddress', width:200, align:"left", sortable:false},
		   		{name:'flag', index:'flag', width:70, align:"left", sortable:false, edittype:'select', formatter:'select', editoptions:{value:"0:否;1:是"}},
		   		{name:'controllFlag', index:'controllFlag', width:70, align:"left", sortable:false, edittype:'select', formatter:'select', editoptions:{value:"0:否;1:是"}},
			],
            sortname:'id',   
            // sortorder:'asc',
            viewrecords:true, 
            pgtext : "页 {0} 共 {1}页",
            recordtext:'记录 {0} - {1} 总记录数 {2}',  
            emptyrecords : "无数据",
            loadtext : "获取数据中...",
            rowNum: 15,//10,   
            loadonce: true,
            //rowList:[10,20,30],   
            jsonReader: { 
				repeatitems:false,   	 // 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
				root: "rows",               // 数据行（默认为：rows）   
				total: "total",        // 总记录数   
				page: "page",            // 当前页   
				records: "records"
                //root:"dataRows",        // 数据行（默认为：rows）
                //page: "pages",    // 当前页
                //total: "totals",  // 总页数
                //records: "records",  // 总记录数
                //repeatitems : false    
            }, 
            //prmNames : {
				//search : "search",
				//rows:"pageModel.rows",
				//page:"pageModel.page",
				// sort:"page.orderBy",
				// order:"page.order"
			//}, 
            pager:"#gridPager",  
            caption: "用户信息 "
		});  
		$("#gridTable").jqGrid('navGrid','#gridPager',{edit:false,add:false,del:false});
		
		//将gird中的0转换为否，1转换为是
		var n = $("#gridTable").getGridParam("rowNum");     //取得现在表格中显示的数据条数
        for(i=1;i<=n+1;i++)                                     
        {
        	var data =$("#gridTable").getRowData(i);    //取该行的值array
            switch(data.flag){
            	case '0': $("#gridTable").setCell(i,"flag",'否');break;
                case '1': $("#gridTable").setCell(i,"flag",'是');break;
                default:  $("#gridTable").setCell(i,"flag",'否');break;
            }
            switch(data.controllFlag){
        		case '0': $("#gridTable").setCell(i,"controllFlag",'否');break;
        		case '1': $("#gridTable").setCell(i,"controllFlag",'是');break;
        		default:  $("#gridTable").setCell(i,"controllFlag",'否');break;
            }
        }
		//
		
		// 配置对话框
		$("#consoleDlg").dialog( {
			autoOpen : false,
			modal : true, // 设置对话框为模态（modal）对话框
			resizable : true,
			width : 480,
			buttons : { // 为对话框添加按钮
				"取消" : function() {
					$("#consoleDlg").dialog("close")
				},
				"添加" : addUserInfo,
				"保存" : updateUserInfo,
				"删除" : deleteUserInfo
			}
		});  
		
		//设置站点关联的模态对话框
		$("#userSitesDiv").dialog( {
			autoOpen : false,
			modal : true, // 设置对话框为模态（modal）对话框
			resizable : true,
			width : 600,
		});  
		
		//初始化对话框中的角色下拉框
		$.ajax({
			type: "POST",
			url : getContextPath()+"/authority/roles/getAllRolesObj.do", 
			data : {},
			dataType : "json",
			async : false,
			cache: false,
			error : function(textStatus, errorThrown) {
				alert("系统ajax交互错误: " + textStatus);
			},
			success : function(data, textStatus) {
				if (data != null) {
					var roleSelect = $("#consoleDlg").find("#eRoleName");
					for (var i=0; i<data.length; i++) {
						//ie8下不支持
						//roleSelect.append(new Option(data[i].name, data[i].id));
						roleSelect.append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
					}
				}
			}
		});
		
		//初始化对话框中的alarm下拉框
		$.ajax({
			type: "POST",
			url : getContextPath()+"/base/alarmConfig/getAllAlarmConfigsObj.do", 
			data : {},
			dataType : "json",
			async : false,
			cache: false,
			error : function(textStatus, errorThrown) {
				alert("系统ajax交互错误: " + textStatus);
			},
			success : function(data, textStatus) {
				if (data != null) {
					var alarmSelect = $("#consoleDlg").find("#alarm");
					for (var i=0; i<data.length; i++) {
						//ie8不支持
						//alarmSelect.append(new Option(data[i].alarmID+":"+data[i].alarmName, data[i].id));						
						alarmSelect.append('<option value="'+data[i].id+'">'+data[i].alarmID+":"+data[i].alarmName+'</option>');
					}
				}
			}
		});
	}
)

		// getContextPath
		function getContextPath() {
    		var pathName = document.location.pathname;
    		var index = pathName.substr(1).indexOf("/");
    		var result = pathName.substr(0,index+1);
    		return result;
		};

		var openDialog4Adding = function() {  
			var consoleDlg = $("#consoleDlg");  
			var dialogButtonPanel = consoleDlg.siblings(".ui-dialog-buttonpane");  
			consoleDlg.find("input").removeAttr("disabled").val("");  
			dialogButtonPanel.find("button:not(:contains('取消'))").hide();  
			dialogButtonPanel.find("button:contains('添加')").show();  
			consoleDlg.dialog("option", "title", "添加区域信息 ").dialog("open");  
		};  
		
		var openDialog4Updating = function() {
			var consoleDlg = $("#consoleDlg");  
	        var dialogButtonPanel = consoleDlg.siblings(".ui-dialog-buttonpane");    
	        consoleDlg.find("input").removeAttr("disabled"); 
	        consoleDlg.find("#eID").attr("disabled", true);
	        //这里不能修改密码，因为密码无法传回
	        consoleDlg.find("#ePassword").attr("disabled", true);
	        consoleDlg.find("#ePassword2").attr("disabled", true);
	        dialogButtonPanel.find("button:not(:contains('取消'))").hide();  
	        dialogButtonPanel.find("button:contains('保存')").show();  
	        consoleDlg.dialog("option", "title", "修改区域信息");  
	          
	        loadSelectedRowData();  
		};
		
		var openDialog4Deleting = function() {
			var consoleDlg = $("#consoleDlg");  
	        var dialogButtonPanel = consoleDlg.siblings(".ui-dialog-buttonpane");         
	        consoleDlg.find("input").attr("disabled", true); 
	        consoleDlg.find("select").attr("disabled", true); 
	        dialogButtonPanel.find("button:not(:contains('取消'))").hide();  
	        dialogButtonPanel.find("button:contains('删除')").show();  
	        consoleDlg.dialog("option", "title", "删除区域");  
	          
	        loadSelectedRowData();  
		};
		
		var loadSelectedRowData = function() {
			var selectedRowId = $("#gridTable").jqGrid("getGridParam", "selrow");
	    	//alert("selectRowID:"+selectedRowId);
	    	if (!selectedRowId) {
	    		alert("请先选择需要编辑的行!");
	    		return false;
	    	} else {
	    		var params = {"eid" : selectedRowId};
	    		// 从Server读取对应ID的JSON数据
	    		$.ajax( {
	    			type:"POST",   
	    			url : getContextPath()+"/authority/users/getUserByID.do",
	    			data : params,
	    			dataType : "json",
	    			//contentType: "application/json",
	    			cache : false,
	    			async:false,
	    			error : function(textStatus, errorThrown) {
						alert("系统ajax交互错误: " + textStatus.responseText);
					},
					success : function(data, textStatus) {
						// 如果读取结果成功，则将信息载入到对话框中     
						var rowData = data;
						var consoleDlg = $("#consoleDlg");

						consoleDlg.find("#eID").val(rowData.id);
						//alert("hiddenID1:"+consoleDlg.find("#selectId").val());
						consoleDlg.find("#eName").val(rowData.name);
						consoleDlg.find("#ePassword").val(rowData.password);
						consoleDlg.find("#ePassword2").val(rowData.password);
						consoleDlg.find("#eMobilePhone").val(rowData.mobilePhone);
						consoleDlg.find("#eMailAddress").val(rowData.mailAddress);
						consoleDlg.find("#eRoleName").val(rowData.role.id);
						//consoleDlg.find("#eRoleNameoption[text=\""+rowData.role.name+"\"]").attr("selected", true); 
						if (rowData.flag == "1")
							consoleDlg.find("#eFlag").attr("checked", true)
						else
							consoleDlg.find("#eFlag").attr("checked", false);
						if (rowData.controllFlag == "1")
							consoleDlg.find("#eControllFlag").attr("checked", true)
						else
							consoleDlg.find("#eControllFlag").attr("checked", false);
						consoleDlg.find("#alarm").val(rowData.alarm.id);
						consoleDlg.find("#longitude").val(rowData.longitude);
						consoleDlg.find("#latitude").val(rowData.latitude);
						consoleDlg.find("#mapZoom").val(rowData.mapZoom);
						
						// 根据新载入的数据将表格中的对应数据行一并更新一下
						var dataRow = {
								id : rowData.id, // 从Server端得到系统分配的id  
								name : rowData.name,
								"role.name" : rowData.role.name,
								mobilePhone : rowData.mobilePhone,
								mailAddress : rowData.mailAddress,
								flag : rowData.flag,
								controllFlag : rowData.controllFlag,
						};

						$("#gridTable").jqGrid("setRowData", data.id, dataRow);

						// 打开对话框
						consoleDlg.dialog("open");
					}
	    		});
	    	}
		};
		
		var checkValid = function() {
	    	var consoleDlg = $("#consoleDlg");
	    	var eID = $.trim(consoleDlg.find("#eID").val());
	    	if (eID=="") {
	    		alert("'用户帐号'为必填信息");
	    		return false;
	    	}
			var eName = $.trim(consoleDlg.find("#eName").val());
			if (eName=="") {
	    		alert("'用户姓名'为必填信息");
	    		return false;
	    	}
			var ePassword = $.trim(consoleDlg.find("#ePassword").val());
			var ePassword2 = $.trim(consoleDlg.find("#ePassword2").val());
			if (ePassword != ePassword2) {
				alert("密码与确认密码不一致!");
				return false;
			}
			if (ePassword=="") {
	    		alert("'用户密码'为必填信息");
	    		return false;
	    	}		
			var eRoleID = $.trim(consoleDlg.find("#eRoleName").val());
			if (eRoleID=="no") {
	    		alert("'用户角色'为必选信息");
	    		return false;
	    	}	 
			var item = $.trim(consoleDlg.find("#alarm").val());
	    	if (item=="no") {
	    		alert("'报警级别'为必填信息");
	    		return false;
	    	}  
	    }
		
		var addUserInfo = function() {
			var consoleDlg = $("#consoleDlg");

			if (checkValid()==false) return false;
			
			var eID = $.trim(consoleDlg.find("#eID").val());
			var eName = $.trim(consoleDlg.find("#eName").val());
			var ePassword = $.trim(consoleDlg.find("#ePassword").val());
			var ePassword2 = $.trim(consoleDlg.find("#ePassword2").val());
			var eMobilePhone = $.trim(consoleDlg.find("#eMobilePhone").val());
			var eMailAddress = $.trim(consoleDlg.find("#eMailAddress").val());
			var eRoleID = $.trim(consoleDlg.find("#eRoleName").val());
			if (consoleDlg.find("#eFlag").attr("checked"))
				var eFlag = "1"
			else
				var eFlag = "0";	
			if (consoleDlg.find("#eControllFlag").attr("checked"))
				var eControllFlag = "1"
			else
				var eControllFlag = "0";
			var ealarmID = $.trim(consoleDlg.find("#alarm").val());
			var elongitude = $.trim(consoleDlg.find("#longitude").val());
			var elatitude = $.trim(consoleDlg.find("#latitude").val());
			var eMapZoom = $.trim(consoleDlg.find("#mapZoom").val());
			
			var params = {
					"eID" : eID,
					"eName" : eName,
					"ePassword" : ePassword,
					"eMobilePhone" : eMobilePhone,
					"eMailAddress" : eMailAddress,
					"eRoleID" : eRoleID,
					"eFlag" : eFlag,
					"eControllFlag" : eControllFlag,
					"eAlarmID" : ealarmID,
					"elongitude" : elongitude,
					"elatitude" : elatitude,
					"eMapZoom" : eMapZoom
			};

			var actionUrl = getContextPath()+"/authority/users/addUser.do";

			$.ajax( {
					type: "POST",
					url : actionUrl,
					data : params,
					dataType : "json",
					cache : false,
					error : function(textStatus, errorThrown) {
						alert("系统ajax交互错误: " + textStatus);
					},
					success : function(data, textStatus) {
						if (data != null) {
							var dataRow = {
									id : data.id, // 从Server端得到系统分配的id  
									name : data.name,
									"role.name" : data.role.name,
									mobilePhone : data.mobilePhone,
									mailAddress : data.mailAddress,
									flag : data.flag,
									controllFlag : data.controllFlag,
							};

							var srcrowid = $("#gridTable").jqGrid("getGridParam",
									"selrow");

							if (srcrowid) {
								$("#gridTable").jqGrid("addRowData",
										data.id, dataRow, "before",
										srcrowid);

							} else {
								$("#gridTable").jqGrid("addRowData",
										data.id, dataRow, "first");
							}
							consoleDlg.dialog("close");

							alert("用户信息添加操作成功!");

						} else {
							alert("用户帐号重复，添加操作失败!");
						}
					}
				});  
		};
		
		var updateUserInfo = function() {
			var consoleDlg = $("#consoleDlg");

			if (checkValid()==false) return false;
			
			var eID = $.trim(consoleDlg.find("#eID").val());
			var eName = $.trim(consoleDlg.find("#eName").val());
			var ePassword = $.trim(consoleDlg.find("#ePassword").val());
			var ePassword2 = $.trim(consoleDlg.find("#ePassword2").val());
			var eMobilePhone = $.trim(consoleDlg.find("#eMobilePhone").val());
			var eMailAddress = $.trim(consoleDlg.find("#eMailAddress").val());
			var eRoleID = $.trim(consoleDlg.find("#eRoleName").val());
			if (consoleDlg.find("#eFlag").attr("checked"))
				var eFlag = "1"
			else
				var eFlag = "0";	
			if (consoleDlg.find("#eControllFlag").attr("checked"))
				var eControllFlag = "1"
			else
				var eControllFlag = "0";
			var ealarmID = $.trim(consoleDlg.find("#alarm").val());
			var elongitude = $.trim(consoleDlg.find("#longitude").val());
			var elatitude = $.trim(consoleDlg.find("#latitude").val());
			var eMapZoom = $.trim(consoleDlg.find("#mapZoom").val());
			
			var params = {
					"eID" : eID,
					"eName" : eName,
					"ePassword" : ePassword,
					"eMobilePhone" : eMobilePhone,
					"eMailAddress" : eMailAddress,
					"eRoleID" : eRoleID,
					"eFlag" : eFlag,
					"eControllFlag" : eControllFlag,
					"eAlarmID" : ealarmID,
					"elongitude" : elongitude,
					"elatitude" : elatitude,
					"eMapZoom" : eMapZoom
			};

			var actionUrl = getContextPath()+"/authority/users/updateUser.do";

			$.ajax( {
				type : "POST",
				url : actionUrl,
				data : params,
				dataType : "json",
				cache : false,
				error : function(textStatus, errorThrown) {
					alert("系统ajax交互错误: " + textStatus);
				},
				success : function(data, textStatus) {
					if (data != null) {
						var dataRow = {
								id : data.id, // 从Server端得到系统分配的id  
								name : data.name,
								"role.name" : data.role.name,
								mobilePhone : data.mobilePhone,
								mailAddress : data.mailAddress,
								flag : data.flag,
								controllFlag : data.controllFlag,
						};
						alert("用户信息更新成功!");
						consoleDlg.dialog("close");
						$("#gridTable").jqGrid("setRowData", data.id, dataRow);
					} else {
						alert("用户帐号重复，修改操作失败!");
					}
				}
			});
		};
		
		var deleteUserInfo = function() {
			var consoleDlg = $("#consoleDlg");  
			
			var r=confirm("确认要删除该信息吗？");
			if (r==false) {
				consoleDlg.dialog("close"); 
				return false;
			}
	        
			var pId = $.trim(consoleDlg.find("#eID").val()); 
	        var params = {"eID" : pId};  
	        var actionUrl = getContextPath() + "/authority/users/deleteUser.do";
	        $.ajax({  
	        	type : "POST",
	            url : actionUrl,  
	            data : params,  
	            //dataType : "json",  
	            cache : false,  
	            error : function(textStatus, errorThrown) {  
	                alert("系统ajax交互错误: " + textStatus);  
	            },  
	            success : function(data, textStatus) {  
	                if (data == "success") {  
	                    $("#gridTable").jqGrid("delRowData", pId);  
	                    consoleDlg.dialog("close");  
	                    alert("用户信息删除成功!");  
	                } else {  
	                    alert("删除操作失败!");  
	                }  
	            }  
	        });  
		};
		
		//与站点关联
		var openDialog4DSiteRelating = function() {
			var selectedRowId = $("#gridTable").jqGrid("getGridParam", "selrow");
	    	//alert("selectRowID:"+selectedRowId);
	    	if (!selectedRowId) {
	    		alert("请先选择需要编辑的行!");
	    		return false;
	    	}
			var mapDlg = $("#userSitesDiv"); 
	        //mapDlg.find("input").removeAttr("checked");
			//mapDlg.find("input").attr("checked",true);
	        mapDlg.dialog("option", "title", "用户站点关联");
	        mapDlg.dialog("option", "height", 370);
	        //根据ajax结果初始化所有的checkbox
	        var actionUrl = getContextPath() + "/site/site/getAllSitesObjOrderByProvince.do";
	        $.ajax({
	        	type : "POST",
	            url : actionUrl,  
	            data : {}, 
	            dataType : "json",  
	            async : false,
	            cache : false,  
	            error : function(textStatus, errorThrown) {  
	                alert("系统ajax交互错误: " + textStatus);  
	            },  
	            success : function(data, textStatus) {  
	            	if (data != null) {
	            		//表格对象初始化
	            		$("#userSitesForm").find("#userSitesTb").remove();
	            		var tr = $("<tr></tr>");
	            	    var td = $("<td></td>");
	            	    var table = $("<table></table>");
	            	    table.attr("id","userSitesTb").attr("class","customPromptTb");
	            	    table.append($("<tr><th width=\"20%\">区域</th><th>站点</th>	</tr>"));
	            	    var curProvince = "";
	            	    var objTr = null;
	            	    var objTd1 = null, objTd2 = null;
	            	    var objInput = null;
	            		//获得了当前的所有site列表,并且以province排序
	            		for (var i=0; i<data.length; i++) {
	            			if (data[i].area.province!=curProvince) {
	            				curProvince = data[i].area.province;
	            				if (objTd1!==null && objTd2!=null) {
	            					objTr.append(objTd1);
		            				objTr.append(objTd2);
		            				table.append(objTr);
	            				}
	            				objTr = tr.clone();
	            				objTd1 = td.clone();
	            				objTd1.append(data[i].area.province);
	            				objTd2 = td.clone();
	            				objInput = $("<input type='checkbox' value='"+data[i].id+"'>"+data[i].name+"</input>");
	            				//objInput.attr("type","checkbox").attr("value",data[i].id);
	            				//objInput.append(data[i].name);
	            				objTd2.append(objInput);
	            				
	            				
	            			}
	            			else {
	            				objTd2.append($("<br>"));
	            				objInput = $("<input type='checkbox' value='"+data[i].id+"'>"+data[i].name+"</input>");
	            				objTd2.append(objInput);
	            			}
	            		}
	            		if (objTd1!==null && objTd2!=null) {
        					objTr.append(objTd1);
            				objTr.append(objTd2);
            				table.append(objTr);
        				}
	            		$("#userSitesForm").append(table);
					}
	            }
	        });
	        
	        //根据UserSite初始化checkbox
	        var actionUrl = getContextPath() + "/authority/users/getAllSitesByUser.do";
	        $.ajax({
	        	type : "POST",
	            url : actionUrl,  
	            data : {"userid" : selectedRowId}, 
	            dataType : "json",  
	            cache : false, 
	            async : false,
	            error : function(textStatus, errorThrown) {  
	                alert("系统ajax交互错误: " + textStatus);  
	            },  
	            success : function(data, textStatus) {  
	            	if (data != null) {
						for (var i=0; i<data.length; i++) {
							$("input[type='checkbox'][value='"+data[i].id+"']").attr("checked",true);						
						}
					}
	            }
	        });
	        
	        mapDlg.dialog("open"); 
		}
		
		var closeUserSiteRelating = function() {
			$("#userSitesDiv").dialog("close")
		};
		
		var selectAllSites = function() {
			$("#userSitesDiv").find("input").attr("checked",true);
		};
		
		var setUserSiteRelating = function() {
			//添加用户站点关联
			//得到选中的集合
			//var selIDs = new Array();
			var selIDs = "";
			var selitems = $("input[type=\"checkbox\"]:checked").each(function(){
				//selIDs.push($(this).val());
				selIDs += $(this).val() + ",";
			});
			//alert(selIDs);
			var selectedRowId = $("#gridTable").jqGrid("getGridParam", "selrow");
			var params = {"userID" : selectedRowId , "siteIDs" : selIDs};
			//var params = {"roleID" : selectedRowId , "menuIDs" : ["111","222"]};
			var actionUrl = getContextPath() + "/authority/users/setUserSites.do";
			$.ajax({
	        	type : "POST",
	            url : actionUrl,  
	            data : params, 
	            //dataType : "json",  
	            cache : false,  
	            error : function(textStatus, errorThrown) {  
	                alert("系统ajax交互错误: " + textStatus);  
	            },  
	            success : function(data, textStatus) {  
	            	if (data == "success") {  
	            		$("#roleMenuDiv").dialog("close");  
	                    alert("用户站点关联成功!");  
	                } else {  
	                    alert("用户站点关联失败!");  
	                }  
	            }
	        });
		}
		
		//与站点关联
		var openDialog4DSiteRelating2 = function() {
			var selectedRowId = $("#gridTable").jqGrid("getGridParam", "selrow");
	    	//alert("selectRowID:"+selectedRowId);
	    	if (!selectedRowId) {
	    		alert("请先选择需要编辑的行!");
	    		return false;
	    	}
			var mapDlg = $("#userSitesDiv"); 
	        //mapDlg.find("input").removeAttr("checked");
			//mapDlg.find("input").attr("checked",true);
	        mapDlg.dialog("option", "title", "用户站点关联");
	        //mapDlg.dialog("option", "height", 370);
	        //根据ajax结果初始化所有的checkbox	        	        	       	    	        
	        $("#usTable").jqGrid({   
	            url:getContextPath()+"/site/site/getAllSites.do",   
	            datatype: "json",// "local",
	            height: 350, //"auto"   
	            colNames:['编号','站点名称','监测类别','区域','流域', '水系', '断面','评测标准'],
				colModel:[
					{name:'id', index:'id', width:70, align:"left"},
					{name:'name', index:'name', width:150, align:"left"},
					{name:'monitorType.name', index:'monitorType.name', width:100, align:"left"},
					{name:'area.province', index:'area.province', width:70, align:"left"},
			   		{name:'valley.name', index:'valley.name', width:100, align:"left"},
			   		{name:'valley.waterSystem', index:'valley.waterSystem', width:100, align:"left"},
			   		{name:'valley.alongSide', index:'valley.alongSide', width:100, align:"left"},
			   		{name:'qualityName', index:'qualityName', width:100, align:"left"}
				],
	            sortname:'id',   
	            // sortorder:'asc',
	            viewrecords:true, 
	            pgtext : "页 {0} 共 {1}页",
	            recordtext:'记录 {0} - {1} 总记录数 {2}',  
	            emptyrecords : "无数据",
	            loadtext : "获取数据中...",
	            rowNum: 15,//10,   
	            loadonce: true,
	            multiselect: true,
	            //rowList:[15, 30],   
	            jsonReader: { 
					repeatitems:false,   	 // 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					root: "rows",               // 数据行（默认为：rows）   
					total: "total",        // 总记录数   
					page: "page",            // 当前页   
					records: "records"
	                //root:"dataRows",        // 数据行（默认为：rows）
	                //page: "pages",    // 当前页
	                //total: "totals",  // 总页数
	                //records: "records",  // 总记录数
	                //repeatitems : false    
	            }, 
	            //prmNames : {
					//search : "search",
					//rows:"pageModel.rows",
					//page:"pageModel.page",
					// sort:"page.orderBy",
					// order:"page.order"
				//}, 
	            pager:"#gridPager",  
	            caption: "站点信息 "
			});  
			$("#usTable").jqGrid('navGrid','#usPager',{edit:false,add:false,del:false});
			
			mapDlg.dialog("open"); 
	      
		}
		
		var showSelected = function() {
			var s;
			s = jQuery("#usGrid").jqGrid('getGridParam','selarrrow');
			alert(s);
		}